﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace splashScreen
{
    public partial class ConsultarProjeto : Form
    {
        SqlConnection conect = new SqlConnection("Data Source=localhost;Initial Catalog=PDSD;Persist Security Info=True;User ID=sa;Password=senha");
        public ConsultarProjeto()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text == "Nome")
                {
                    string query = "select * from Projeto where nomeProjeto like '%" + textBox1.Text + "%'"; ;
                    SqlCommand com = new SqlCommand(query, conect);
                    conect.Open();
                    com.CommandType = CommandType.Text;
                    SqlDataAdapter da = new SqlDataAdapter(com);
                    DataTable Projeto = new DataTable();
                    da.Fill(Projeto);
                    projetoDataGridView.DataSource = Projeto;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conect.Close();
            }
        } 
    }
}
